Inelegant brute force solution