added #if debug so that logging is only enabled in debug