minor analysis script refactoring