Edited so it doesn't break quite so badly, still got problems I assume though