next prev function fix