implement feature request #1489

Signed-off-by: Umair Khan <omerjerk@gmail.com>
Replace if condition with a better code

Signed-off-by: Umair Khan <omerjerk@gmail.com>
Merge pull request #866 from omerjerk/QA_4_1

implement feature request #1489