deleted dead code and added missing throw