added debug parameter in case we need to add debug print statements for
testing purposes.