added total stats, and refac
proper sql query (time > `time`)