refactor return error structure