moved conditions to separate "if" statement