fixed bug for missing end to wait method
added a check if the system exists in stack_wait method