added beginning of loop