some more refactoring
allow running locally too