adding loading function