added dying logic
added dying logic