neat code for more template and code for dist to wall