adding loading functionality