Added better separation of code and DRY.