refactor for production