these three if-statements are completely the same in both methods, lets move it to separate method