modify main to make use of new functions