moved variable processing outside of error/no error