fixing dictionary length bug