refactoring

refactored for loops and variable names
fixing OO