improved message editing. made code more idiomatic