I think this could be simplified or modified, but nothing comes to mind. Does anyone have a solution how to make this code faster? (Those dashes are for understanding how deep i