fixed checks on db