rewritten via scanf