move code into conditional block