Fix bug with position values after replace