removed duplicated code and fixed my added code indentation