faster approach to naive