finish main function ,test,improving datails