Changed main file to allow for batch execution