I know, the code is horrible, but I welcome suggestions