Updated code to work independantly of different analysis types