Fixed nested functions