refactored code around sensor library example