improved solution for 8, added 11, 12