reworked bad logic