cleaned up update loop