Cleaned up a bit - appears to be working!