Improvment for ctx handling