Cleaned up update_record function.