Refactored and added some features