Fixed error. Using index rather than recursive return object