complete main function
debug