added check to enable running in terminal