Fixed a bug where the output was always 1