better MOTD detection code