added figure generation stuff