swapped containsKey with null check