Database logic updated