Fixed checkpermissions