group several code to function