ugly code for my dear teacher