moved functionailty out of main Program