refectored main activity code and added a refresh button