Convert to class instead of global functions