refactor sensors code