fixed bugs, add interanl functions, add category data