Simplify the check by using convenience functions from HashMap