Fixed update logic
Better error handling