Added a access check function to replace the manual access check in each function