[BUGFIX] Harden database select step