finished adding error checking