Refactoring of redundant code. And management of null values.