added a flag to enable logging