Fix wrong if statements
Add comments