Removed dead code and made error more relevant