added slow (cubic-time) algo