working again! just need to make the code pretty and test it