Refactored some code
Replaced deprecated code