Created a nested function block.

made a function and nested with an if/else.