refactored code to ease usage, improved error plots