changed some parameter from int to long