Modularized the reference viewer script