Make compile function more async