update checkDatabase function

still need review!