refactored with enums. fixes issue 1