refactored to handle multiple sensors