in reply to subroutine inside subroutine
The code you posted is broken in multiple dimensions, no idea where to start...
Cheers Rolf