firstTop should be stored per element

The `firstTop` variable stores the top of the first element only, should instead store per element.