correct errors in optimize tacking logic