Fix for variable error and array to string conversion problem