my extremely inefficient solution