better way of calculation