Updated functions and correctly increment id attributes