Revert "Fixed some code duplication"

This reverts commit be8b03660b9ea88eb1b215c61e65380261384a69.