Refactored stuff into methods