refactored err to e