Improve your code little bit

Your code had problems with list range and with redundant arguments. So, if you want, there are my improves for your code.