Fix bug in sub