Enhancing flame retardancy of polymer nanocomposites