Error and methods refactored