optimizes untaken position function