Explicitly handler undef exception in the try/catch statement
Removed debugging statements