separated logic and main method