Keeping 50 items needs to use ltrim 0 49, not ltrim 0 50.