Fix for loading state
Refactoring