Modified handle_INSERT function, make it work as a toggle