Implemented insertion as described on Wikipedia