added c function to get total