Fixed the update loop