Refactored using one of spark fun examples