Bug fix: error might be nil