change variable names and added console log outputs