Refactored by using external libraries