added #58, needs refactoring for speed