deduplicate code, use little hack for errors, accept negative numbers
fix lie