implemented suggestions by whyrusleeping