adjusted and added checks

had ill-placed parens and added console logs for variables