make everything DRYer / refactor / bugfix