Refactored, added dotProduct method