basic algo works for naive cases