Corrected database implementation