fixed type problems
flag setting for adding