done but needs testing possible refactoring