changed result type to an integer