Taking into account distance from obstacles