My first solution. And it works!