throwing Error instead of returning a value