Refactore error locations handling