turn view into a loop to avoid code repetition