modified for compatibility with ie7