Updated Sample Code

Corrected helper function, refactored all objects under main.