Added elsif statements

Now works better with nested statements