better function and block handling