camera freeze after photo solved and code refactoring