minor error fixes
added console.log debugging