main function implemented