moving index to patterns