Using foreach() would be much cleaner here.