implemented main function