structure the code better