added postgres funtion