Fixed a bug in database