modify loops and array initialization
modify $ to @, to make proper instance variables