fix dict key check logic