refactor to solve using objects