Refactoring: remove code duplication

Removed `getFieldLength` function so there is no code duplication at all now. 
Probably good to merge to 'master'? :)