more generic to allow use of the debug flag