Proper endstate element generation
fix for if element generation