changed javascript code to jquery