refactor errors and message