rewrote if statements and logic