this part I didn't have time to refactor it, these stupid if conditions should be refined.