fix formatting in sample code output
refactor common service code into shared service