Definitely need to rewrite this again....