Refactored extract class name to the prototype of an function

This allows the reuse of the function in more cases