Fixed bug with database