fixed duplication in next page function