modularizing plotting