Refactor the innermost loop of the xdraws function