added the first implementation for least square