Error handling and debugging (added sleep for off)