Fixed two function declatations that whas inside blocks

Replaced them with function expressions instead.

Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function.