Optimize jQuery code a bit