Changed get perm routine
rewrote getPerm in functional way