Refactored application to prevent loading bug