generalize messages and get rid of a few ifs