Review and update

Corrected a few logical errors through program