ugly code ...