used new keyword instead of temp variables
Formatting
used ! instead of ==0
implemented "sanitycheck"

also removed unnessesary variables