using already existing code (python) and tranlating it to ruby, rectangle ready, needs testing