Fixed get next/previous calculations