Move functionality out into methods