fixed indentation
removed duplicate code