fixed main to new functions