refactored with namespaced javascript