Rewrite. Potential mistake
Fixed all remaining bugs labeled more variables