Merge all operations in one single function to make easy to read and satisfy the conditions for most of operation