Moving printed results to standalone function. Adding new main function.