cleaned up duplicate code, fixed domain prob