Changed: Re-factored the code.