Converted some functions to jquery