before and after function added