extracting index and remove logic to specific classes