fix end code