refactored, works for non-certified apps