moved all gets and prints to functions, except the opening checks, issue #26