Moved the functions in to a class