removed debugging prints and added final output