moved some php code out of views (js only now)