first functional version; plenty of print statements