Fixed bug in database method