rewrote recent function for db access