optimized code and removed some old shit