almost Done,need code review,sometimes crash