Consolidated duplicate code into methods.