removed redundant if and fixed indentation