added check for debug flag