making changes as per @agramfort requirement and making the code pep8 compilant