move if outside of forloop