Fixes max occurrence check not working correctly