Fully Functional

Could be optimized to be more precise but resolves small problems.