Re-factor. As per comments on the Pull Request.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>