rewrite index.py printing code to be slightly more elegant