Refactor ready to move away from time.sleep calls