adapted work under postgresql