added case class extraction and parameter validation