fix calling keys on array and refactor