refactored method registration, shaving off loads of repeated code
updated generate template