code style improve and fix the stackoverflow bug