Improved solution for Number9