updated code, mostly mesif