need to improve total calculation