improving solution for 2.4