Updated function window to prevent jQuery Bug