Fixing the adding of keys, the key array was intialized as string not array.