This works, but curious why you didn't just write it as a template file.