Works wew, apart from the extra loop