restoring logic with beefed up checks