code working but tones of improvement needed