added dying logic