implemented @ceejbot's suggestions
implemented @ceejbot's suggestions