change moveToElement logic