initial implementation stripped from the sudplan project, needs further adaption