replaced total time sum with sqlite func