added loop to minimize the amount of code