changed raw javascript to jquery