Added missing error checking