using manhatan distance in cost function