added warnings and refactored code with modern syntax #1