Optimized code and added an edit page to category