A much speedier version using pipes