fix the last entry issue properly