refactored client code - check drum_machine.js for example