cleaned up code by replacing count with entryId