refactored dividing the data