separated script so that there is now one for pattern and for graphs