Inelegant solution but fast and precise solution.