solution for 002
better solution 002