major refactor to structure the application correctly