Added total function and some minor changes