mod: refactory code