cleaning up popup code