delete a empty else branch
modify code to pass scala style checks