Quick dirty fix for a nullpointerexception but this has to be looked in to.