refactored code by moving the class in to the server file