added max_id def, not currently working though :(