Code refactored for compactness and readability.

Refactored the code to enhance readability.

https://bugzilla.redhat.com/show_bug.cgi?id=1073083
https://github.com/ManageIQ/manageiq/issues/138#event-148990147