2nd attempt. This time using postgres