check permissions, fix bugs