refactored old functionality into new implementation