Added functionality for loading previous state