fixed missing conditional at the end