Changed indexing procedure for speed