DOC and renamed some variables for clarity