Changed the programm two use integers instead of chars. It's working without bugs now. I'm proud of myself :D