fix bug in key lookup