modified for main functions