improve relay lib