Added checks for callback before attempting to run it

Using the pinMode function specifically, calls without a callback caused the script to throw an error when the callback function was ran when it was undefined.