refactor
add compatibility functions for array idioms
fix IE7 compatibility issue