implemented insert

refactored code and implemented recursive insert method

issue#1