BugFix: move variable to main function, so that it can be accessed from all functions