refactored into single js file