Changed implementation to use pipe instead