adding debug mode for testability