refactor a lot