refactored for the front-end