inefficient, but fully functional with both boundary types