solution 2 implemented