refactor conditional for opaque keys