fixed some typos, added some validation checks