working solution, not optimum