trying to fix loop