Add comments
Refactored if statements

Also added comments