Optimized hasEntry method