improved the memory performance of mcPosition; ugly index matrix is now replaced with ugly index function