reorganized detail code/edited book select statement