Added None check for db select