Refactored client code into client folder