optimazed database working