fix bug in key wrapper