added template route type, changed function route type (closure), refactored