1) refactor code; 2) fail with Error object instead of string