Fixing possible bug from array key value pairs