slight refactoring done