need to refactor a lot