refactor code a bit

Signed-off-by: Doug Hellmann <doug.hellmann@gmail.com>