cleaned up some duplicate code