Corrected bug in application handling