fixed ending code