last_msg NoneType error fix