javascript in own file and refactored with some extra functionality