updated main function to use init function