cleaning up bam code