Repetition here from line 26. Can this be refactored?