remove unused template and refactor a bit