Per Mark's suggestion, a little refactoring