Server side code refactor