Adding stopLoading function