Rewrote some functions with pipes