Refactor and add InvalidMethodException