Fixing popup behaviour