modified to use LukeJr:'s new code