really ugly code