remove function
add check when adding an item
minor visual modification
add macro to simplify the code