Refactored everything into a class