Added some more error checking..bam