New algorithm that works + refactored stuff