error and exit handling
end state