refactored javascript to use backbone