Improved update function
Speed ups