added maybe_debug_log function for better troubleshooting issues