add logging statements
streamline PostgreSQL checking logic