Semi Succesful port to postgres