fixed to work on *.force.om
made the checking code a little cleaner
fixed for .force.com pages