Implementing category function