added call to exit() at the end