fix next and pre button click function