removed a bug due to the non coverage of end case