Fixed the bug which caused the global array not being updated and

cleaned up the code. This exercise is done :)