Refactored some code, front end should work the same way