Removed duplicate code

Removed duplicate code and fixed indentation.

Jira issue: WP-919
http://jira.webinos.org/browse/WP-919