refactored 003, as some variable names were confusing, and some comments were inaccurate