updated code for loading better