minor changes, error checking