Improved solution for Q11