Refactoring
Refactored to use pipelining