refactor properly