added brute force solution