solved via brute force and for loops