Rewrite decorator class to decorator function