1) refactored to javascript module