added bar replacement based on templates