script exiting beug fixes