program gives wrong result