cleanup code: moved stuff from main to helper class