Fixed some error checking