More formatting fix plus some error checking