refactored and made interface easier to deal with