modified several functions