Remove old commented-out code and simplified logic