adding checks on insertion