Debugging this not so great solution