move code for easier reading