Refactored subroutines.