Adjusted for postgresql