added even more error checking