refactored client side code into backbone