Implemented javascript function