fixed recursive functions; beefed up printing