optimize check whether user may view paper details

-can be optimized a lot more by using a SQL query