refactor javascript and member security