Mixed up if statements.
Removed debug messages