fixing array key error