moved into class and main func