Shrunk code by converting to jQuery