function insertCategories has been corrected