Trying fix jquery functions bugs