refactored and added private methods