move functionality to function and call it from main