Moved plotting code into separate function