Included glabal parameter passing.
Proper error handling.