preprocess done not fully tested ; model function defs