tidy and switch to forwards for loop in compose to ensure correct order of function execution