fix bugs ralted coding and fix one crash