cleaning up the CoffeeScript and refactoring bulb controls into a single function