This is the workin non-ajax version that I was unable to commit earlier