Updated code according to Tomaz Cerar Pull Request comments