added sub function