trying to understand bug
better match for permissions
style fix
fixed a lot of stuff