re-indented code
using template now so that binding works