added check for empty code