Bad code, will fix (using typeclasses, maybe?)