cleaned up variable processing a bit