making it javascript function