-bug solved and edge case to avoid infinte waiting solved