Decorator for writing local and remote functions