moved main in sep func
Commenting
add more func comments
Added more comments