Refactor: move a constant out a function to avoid repeated calculation