Moved some behaviour to one place

**What does this MR do?**
It moves some duplicated behaviour to one place

**Why is this MR needed?**
Well, its just a refactoring, doesn't fix anything, although it improves CodeClimate score a little