mandel works + refactor