some features on new design
moved code into functions
many changes to conform to new design
fixed more design