fixed bug caused by using improper check for array key

fixed bug caused by using improper check for array key