hacked it all together, though its not really working properly