respecting timeouts, not the best but i think it'll do