refactor this bitch