extracted position logic