Added if-then-else, tested OK with example from the slides.
merged funconstr