updated logic, back to if statement, works on pageload