Added in if statements and some comments