Bug fix: error handleing