fixed missing matplotlib + refactored imports + added some comments + renamed variable