Updated with main function