some of code,not all are mine