fixed some error checking retur values