public method, keys and val can be null