refactored spatial navigation; corrected 'too-many-branches'