refatorated volume function