How I hate this fucking job...
Cleaned up function.