introduced Vector2D, code rewrite to use vectors