fixed bug in main uddate function