only one javascript function runs at a time