Update operations.py to clean dumplicated codes