cleaned up / sped up horrible code
merged