P028: improved solution