added debug messages to catch permission errors