ugly up this method with some branches so I don't forget the logic I wanted