Edited: Cleaned it up a little so it's easier to read.