massive rewrite for insert
first beta, working!!!
changed function name