Fixed bug with position in replace-with-position function