Fixed program flow error