updated based on Andrew Ziem's suggestion