Refactoring by getting rid of magic numbers