Implemented range detection from sensor