working
but needs improvements, not giving the best solution yet