Fixing if-else-endif combo