emergency function working correctly