Fix next being called too many times and add panel counter