main function working