fixes #toClass helper method