this code has been posted before. many times but thanks anyway.