fixed issue with next being called multiple times