added keys and improved indexOf