fixed bug in key check