fix end problem