added second if, yay for clarity