Changed main to use the new functions