Refactored to make all the functions into a single class