refactored pairingmodule.c slightly