Updated - Some code refactoring