fixed "next" and "prev" function