Refactring sample code to demonstrate use of common auth and env.