Switch trial and block code to nested functions. Added feedback log