moving the functions out of the constructor