fixed bugs with database interface