lines with //Omid are mine