updated boolean ending code