modularized some functions