Moved additional code into library
Added dot product