Addressing comments and moving functions to separate file