working solution
better solution