Might need some cleaning up but works Closes #23