- javascript refactored