renamed some signature to avoid calling self
updated for templated version