cleanup/refactor to speed things up