tried to fix error checking?