working but ugly
cleaned up, working (hopefully)