Move functions into class