reverted optimization that broke the logic