add loading functionality