function choose position improved