replaced bad querying of session logged in