fixed accidentally implementing dynamic scoping
cleaned up printing code