added checks for malformed strings