Bug fix: avoid exceptions