this code sucks, needs some more attention later