standardize code
fixed bug in update procedure