now handling errors with debug msgs