improved previous solution