bugfix: use ceil to keep index greater than or equal to 1