updated with empty message checking