Added else for when ID exists
Changed method of acquiring max ID