add working solution for the problem