added permission testing and upgraded and implemented a hasPermission helper function