added sprintf but line 3 of the print stmts doesn't work with sprintf