Improve db check