Some refactoring to remove magic numbers with variables