removed redundancy in error messages by moving message to var