Got rid of code duplication script