crud js logic