moved "lastEntry" declaration