rewriting repeting jquery functions to give more consistency to the code;