public static List<Game> getCurrentGames(EntityManager manager,
			String userMobileHash, String option) throws Exception {
		boolean isAi = "ai".equalsIgnoreCase(option);
		boolean listAll = "all".equalsIgnoreCase(option);
		boolean isUserName = TxtChessUtil.validateUserName(option);
		if (isUserName) {
			ChessUser op = findUserByUserName(manager, option);
			if (op == null)
				throw new Exception("No user exist with name " + option);
			option = op.getMobileHash();
		}
		List<Game> result = new LinkedList<Game>();
		Query query1 = manager.createQuery("select c from "
				+ Game.class.getName() + " c where c.white='" + userMobileHash
				+ "'");
		for (Object obj : query1.getResultList()) {
			if (obj instanceof Game) {
				Game game = (Game) obj;
				if (isAi && TxtChessUtil.isAI_Game(game)) {
					result.add(game);
				} else if (isUserName&&game.getBlack().equals(option)) {
					result.add(game);
				} else if(listAll){
					result.add(game);
				}
			}
		}

		Query query2 = manager.createQuery("select c from "
				+ Game.class.getName() + " c where c.black='" + userMobileHash
				+ "'");
		for (Object obj : query2.getResultList()) {
			if (obj instanceof Game) {
				Game game = (Game) obj;
				if (isAi && TxtChessUtil.isAI_Game(game)) {
					result.add(game);
				} else if (isUserName && game.getWhite().equals(option)) {
					result.add(game);
				} else if(listAll){
					result.add(game);
				}
			}
		}

		return result;
	}