Starting to restructure the code