Converted script to jquery