made the code work both offline and online(to be tested)
bug fixing