Now uses keys with values instead of numerical keys in the input array