Implemented recursive insert method