Fixed error  that was occurring because of an extra quotation mark. Also added conditional validation.