added debug logging functionality