fix typo and use less and reaable code to impl the simple logic