Rewite with a class instead of unrealted vaiables