Refactoring code to use design patterns.

jira : QUES-39