Fixed some logical errors, permission access and view