Resume function working (with a bug)