updated documentation & added error checking