refactored one more javascript function into the static directory