added before and after functions for entity modification