clean code and add private insert handler