Combined code, made delays shorter