Add some error checking in