rewrote all the parts to use library