Early code for position detection