Some code,not all is mine.