Removed code duplication. Yay for DRY!