corrected code to work on Tomtcat 6