adding .hasOwnProperty checks to for loops and correcting improperly terminated statements