refactor sensor reading