further refined my program structure