Moving functions into constructor