commit 6 : refactored code for insert