private BigDecimal computeRatingForMovie(int userId, int movieIndex, List<MeanRating> correlations, Boolean normalize) {
        BigDecimal result = new BigDecimal(0.0);
        BigDecimal correlationsSum = new BigDecimal(0.0);
        int targetUserIndex = ratingsTable.getUserIds().indexOf(userId);

        for (int i = 0; i < correlations.size(); i++) {
            Map<Integer, BigDecimal> currentRating = ratingsTable.getRatingsByUserId(Integer.parseInt(correlations.get(i).getItemName()))
                            .getRatingsMap();
            if (currentRating.containsKey(movieIndex)) {
                correlationsSum = correlationsSum.add(correlations.get(i).getMeanData());
                if (normalize) {
                    int index = ratingsTable.getUserIds().indexOf(Integer.parseInt(correlations.get(i).getItemName()));
                    BigDecimal intermediateResult = currentRating.get(movieIndex).subtract(meanRatings.get(index), new MathContext(6));
                    result = result.add(correlations.get(i).getMeanData().multiply(intermediateResult, new MathContext(6)),
                                    new MathContext(11));
                } else {
                    result = result.add(correlations.get(i).getMeanData().multiply(currentRating.get(movieIndex), new MathContext(6)));
                }
            }
        }
        if (!correlationsSum.equals(BigDecimal.ZERO)) {
            result = result.divide(correlationsSum, new MathContext(11));
            if(normalize)
            result = result.add(meanRatings.get(targetUserIndex));
        } else {
            result = BigDecimal.ZERO;
        }
        return result;
    }