added sensor reading clamping