Refactored code out so that it can be shared with the wear app