Tidied up code a bit pulling out unnecessary jQuery references