refactored javascript using backbone
implementad triggers ans switches