cleaned up a bit for open sourceness