better logging and protect select from not finding data