moved some functions to category directive scope