Refactored and added some more implementation