code refactoring: decoupling back-end and front-end