table code and methods refactored, shell script generalized