use sleep library instead of our sleep fn; also refactor to more cleanly use request library