added calculation of possibilities