fixed some nested statement problems