commenting, error checking improvement, updated exceptions